Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

movevm loaderv2 integration #284

Merged
merged 6 commits into from
Oct 31, 2024
Merged

movevm loaderv2 integration #284

merged 6 commits into from
Oct 31, 2024

Conversation

sh-cha
Copy link
Contributor

@sh-cha sh-cha commented Oct 11, 2024

No description provided.

@sh-cha sh-cha self-assigned this Oct 11, 2024
@sh-cha sh-cha requested a review from a team as a code owner October 11, 2024 08:33
Copy link

coderabbitai bot commented Oct 11, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces several enhancements to the MoveConfig structure, adding new constants and fields related to script and module cache capacities. It also modifies the Keeper struct to streamline virtual machine (VM) initialization and execution by consolidating multiple VM instances into a single reference. The execution methods in the keeper package are updated to remove an indirection layer, allowing for more direct interactions with the VM. Additionally, a previously existing file, vmpool.go, has been deleted, indicating a shift in how VM resources are managed.

Changes

File Path Change Summary
x/move/config/config.go Added constants DefaultScriptCacheCapacity and DefaultModuleCacheCapacity, flags, and fields in MoveConfig. Updated DefaultMoveConfig, GetConfig, and AddConfigFlags functions.
x/move/keeper/genesis.go Modified Initialize method to directly call initiaMoveVM.Initialize, simplifying VM initialization.
x/move/keeper/handler.go Replaced execVM function with direct calls to ExecuteEntryFunction and ExecuteScript methods. Updated method signatures to handle JSON arguments. Removed execVM function.
x/move/keeper/keeper.go Removed fields for managing multiple VM instances; added initiaMoveVM field. Updated NewKeeper constructor to initialize a single VMEngine instance.
x/move/keeper/vmpool.go Deleted file, removing Keeper struct and its VM management functions.
Dockerfile Updated LIBMOVEVM_VERSION from v0.5.1 to v0.6.0.
x/move/keeper/common_test.go Added imports for new IBC modules and updated ModuleBasics to include them.
x/move/keeper/vm_msg_stargate.go Changed HandleVMStargateMsg parameter type from *vmtypes.StargateMessage to *vmtypes.CosmosMessage.
x/move/keeper/vm_msg_stargate_test.go Updated test cases to use CosmosMessage instead of StargateMessage.
x/move/keeper/vm_query.go Added cache context creation for queryCustom and queryStargate methods.
x/move/types/cosmos_message.go Deleted file containing ConvertToSDKMessage function.
x/move/types/keys.go Updated key separators for the move module's store.

Possibly related PRs

🐇 In the meadow, I hop with glee,
New caches for scripts, oh what a spree!
A single VM now leads the way,
Streamlined paths for a brighter day.
With flags and constants, we dance and play,
In this code garden, we’ll leap and stay! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Oct 11, 2024

Dependency Review

The following issues were found:
  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 1 package(s) with unknown licenses.
See the Details below.

License Issues

go.mod

PackageVersionLicenseIssue Type
github.com/initia-labs/movevm0.6.0NullUnknown License
Denied Licenses: GPL-1.0-or-later, LGPL-2.0-or-later

OpenSSF Scorecard

PackageVersionScoreDetails
gomod/github.com/initia-labs/movevm 0.6.0 UnknownUnknown

Scanned Files

  • go.mod

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (2)
x/move/config/config.go (1)

32-33: LGTM! Functions updated to support new cache capacity fields.

The updates to DefaultMoveConfig, GetConfig, and AddConfigFlags functions are consistent with the new fields and flags. These changes ensure proper configuration and retrieval of the new cache capacities.

Consider adding a blank line between the different flag additions in the AddConfigFlags function for improved readability:

 startCmd.Flags().Uint64(flagContractSimulationGasLimit, DefaultContractSimulationGasLimit, "Set the max simulation gas for move contract execution")
+
 startCmd.Flags().Uint64(flagScriptCacheCapacity, DefaultScriptCacheCapacity, "Set the script cache capacity")
 startCmd.Flags().Uint64(flagModuleCacheCapacity, DefaultModuleCacheCapacity, "Set the module cache capacity")

Also applies to: 41-42, 49-50

x/move/keeper/keeper.go (1)

93-94: Consider Enhancing the Panic Message for VM Initialization Errors

Currently, if vm.NewVM returns an error, the code will panic without additional context:

if err != nil {
    panic(err)
}

While panicking may be acceptable during initialization, providing more context in the panic message can aid in debugging.

Consider updating the panic to include an explanatory message:

 if err != nil {
-    panic(err)
+    panic(fmt.Sprintf("Failed to initialize VMEngine: %v", err))
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8414620 and 650815f.

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (5)
  • x/move/config/config.go (2 hunks)
  • x/move/keeper/genesis.go (1 hunks)
  • x/move/keeper/handler.go (3 hunks)
  • x/move/keeper/keeper.go (3 hunks)
  • x/move/keeper/vmpool.go (0 hunks)
💤 Files with no reviewable changes (1)
  • x/move/keeper/vmpool.go
🧰 Additional context used
🔇 Additional comments (8)
x/move/config/config.go (5)

12-13: LGTM! Please verify the default cache capacities.

The addition of DefaultScriptCacheCapacity and DefaultModuleCacheCapacity constants is consistent with the PR objectives. However, please confirm that these default values (100 and 500 respectively) are appropriate for the system's requirements and expected load.


17-18: LGTM! New flags are consistent with existing naming conventions.

The addition of flagScriptCacheCapacity and flagModuleCacheCapacity is consistent with the PR objectives and follows the existing naming convention. This allows for proper configuration of the new cache capacities.


24-25: LGTM! New fields added to MoveConfig struct.

The addition of ScriptCacheCapacity and ModuleCacheCapacity fields to the MoveConfig struct is consistent with the PR objectives. The use of uint64 type and mapstructure tags is appropriate and maintains consistency with the existing structure.


62-65: LGTM! DefaultConfigTemplate updated with new cache capacity entries.

The DefaultConfigTemplate has been correctly updated to include entries for script-cache-capacity and module-cache-capacity. The new entries follow the same format as the existing ones, maintaining consistency in the configuration template.


Line range hint 1-65: Overall, the changes in this file look good.

The modifications to x/move/config/config.go are consistent with the PR objectives of enhancing the MoveConfig structure. The new constants, flags, and fields for script and module cache capacities have been properly integrated into the existing code. The changes maintain good coding practices and consistency with the existing codebase.

A few minor suggestions were made for improvement, but overall, the implementation looks solid.

x/move/keeper/genesis.go (2)

Line range hint 1-214: Overall impact of the change is minimal and focused.

The modification to the Initialize method is the only change in this file. The InitGenesis and ExportGenesis methods remain untouched, suggesting that the change is self-contained and doesn't require adjustments to the overall genesis state management logic.

This focused change aligns well with the PR objective of integrating a new VM loader version, as it simplifies the VM initialization process without affecting other parts of the genesis handling.


50-50: Approve the simplification of VM initialization.

The change simplifies the code by directly calling k.initiaMoveVM.Initialize instead of using a function wrapper. This improves readability and potentially reduces function call overhead.

However, please consider the following:

  1. Ensure that k.initiaMoveVM is always properly initialized before this method is called.
  2. Verify that no important logic or error handling was lost by removing the previous closure.
  3. Confirm that this change doesn't affect error propagation or context handling in unexpected ways.

To ensure the change doesn't introduce any regressions, please run the following verification:

x/move/keeper/keeper.go (1)

44-44: ⚠️ Potential issue

Confirm Thread Safety of initiaMoveVM

The initiaMoveVM field now holds a single VM instance shared across the Keeper. Ensure that the VMEngine implementation is thread-safe and can handle concurrent access without data races or unexpected behavior. Previously, multiple VM instances were managed with a semaphore to control concurrent usage.

To verify the thread safety, you can run the following script to identify all usages of initiaMoveVM and assess whether they are safe:

x/move/keeper/keeper.go Outdated Show resolved Hide resolved
x/move/keeper/keeper.go Show resolved Hide resolved
x/move/keeper/handler.go Show resolved Hide resolved
x/move/keeper/handler.go Show resolved Hide resolved
x/move/keeper/handler.go Show resolved Hide resolved
@beer-1 beer-1 marked this pull request as draft October 16, 2024 07:36
@beer-1 beer-1 changed the title [do not merge] movevm loaderv2 integration movevm loaderv2 integration Oct 31, 2024
@beer-1 beer-1 marked this pull request as ready for review October 31, 2024 06:43
Copy link
Member

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@beer-1 beer-1 merged commit e3ebdd4 into main Oct 31, 2024
4 of 6 checks passed
@beer-1 beer-1 deleted the feat/vm-loaderv2 branch October 31, 2024 06:46
beer-1 added a commit that referenced this pull request Oct 31, 2024
* connect movevm with loaderv2 and introduce module & script cache

* use cache context before query

* disable unstable

* update movevm to latest

* add toml description

---------

Co-authored-by: beer-1 <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2024
11 tasks
beer-1 added a commit that referenced this pull request Oct 31, 2024
* prepare upgrade initiation-2

* fetching code bytes with precompile readlib func

* delete existing upgrade handler

* dont delete if it is module

* add cosmos move

* add get&set checksums, genesis import&export module checksums

* change checksum func

* initialize staking at genesis (#290)

* movevm loaderv2 integration (#284)

* connect movevm with loaderv2 and introduce module & script cache

* use cache context before query

* disable unstable

* update movevm to latest

* add toml description

---------

Co-authored-by: beer-1 <[email protected]>

* wip

* delete keys after iteration

* clone key value

* fix

* reverse iterate vmstore & set keys

* final touch

* update swagger docs

---------

Co-authored-by: beer-1 <[email protected]>
Co-authored-by: beer-1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants